import 'package:flutter/material.dart';
import 'listData.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(primarySwatch: Colors.pink),
        home: Scaffold(
          appBar: AppBar(title: Text('Wrap')),
          body: HomePage(),
        ));
  }
}

class HomePage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {

    return Container(
      height: 600,
      width: 400,
      color: Colors.green,
      padding: EdgeInsets.only(left: 10),
      child: Wrap(
        spacing: 10, // 横向间距（常用）
        runSpacing: -2, // 纵向间距（常用）
        alignment: WrapAlignment.start, // 横轴对齐方式
        runAlignment: WrapAlignment.end, // 纵轴对齐方式
//        direction: Axis.vertical, // 纵轴排序方式
        children: <Widget>[
          MyButton('按钮1'),
          MyButton('按钮2'),
          MyButton('按钮3'),
          MyButton('按钮4'),
          MyButton('按钮5'),
        ],
      ),
    );
    
  }
}

class MyButton extends StatelessWidget {
  String text;
  MyButton(this.text);
  @override
  Widget build(BuildContext context) {
    return RaisedButton(
      child: Text(this.text),
      textColor: Theme.of(context).accentColor,
      onPressed: (){

      },
    );
  }
}
